package com.thecafetechno.main;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.thecafetechno.university.Student;
import com.thecafetechno.util.HibernateUtil;

public class DataPopulator {
	public static void populateData() {
		Student firstStudent = new Student();
		firstStudent.setName("Saurabh");
		firstStudent.setMarks(83);
		firstStudent.setExtraSubject(null);

		Student secondStudent = new Student();
		secondStudent.setName("Pooja");
		secondStudent.setMarks(80);
		secondStudent.setExtraSubject("data mining");

		Student thirdStudent = new Student();
		thirdStudent.setName("Anu");
		thirdStudent.setMarks(73);
		thirdStudent.setExtraSubject(null);

		Student fourthStudent = new Student();
		fourthStudent.setName("pushpi");
		fourthStudent.setMarks(75);
		fourthStudent.setExtraSubject("simulation");

		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		Transaction transaction = session.beginTransaction();

		session.save(firstStudent);
		session.save(secondStudent);
		session.save(thirdStudent);
		session.save(fourthStudent);

		transaction.commit();
	}
}
